/*
 * $Id: $
 */
package org.rcgwt.client.ui.grid.model;

import org.rcgwt.client.ui.grid.IWidgetsRegistry;
import org.rcgwt.client.ui.grid.controller.IGridModelController;
import org.rcgwt.client.ui.grid.event.HasModelChangedHandlers;
import org.rcgwt.client.ui.grid.event.HasPropertyChangedHandlers;
import org.rcgwt.client.ui.grid.event.IModelChangeState;
import org.rcgwt.client.ui.grid.internal.model.IElementModel;
import org.rcgwt.client.ui.grid.internal.model.IGridModel;
import org.rcgwt.client.ui.grid.internal.model.IViewModel;
import org.rcgwt.client.ui.grid.provider.ICheckProvider;
import org.rcgwt.client.ui.grid.provider.IColumnProvider;
import org.rcgwt.client.ui.grid.provider.IOrderProvider;
import org.rcgwt.client.ui.grid.provider.IFocusProvider;
import org.rcgwt.client.ui.grid.provider.IOverProvider;
import org.rcgwt.client.ui.grid.provider.ISelectionProvider;
import org.rcgwt.client.ui.grid.renderer.IGridRenderContext;
import org.rcgwt.client.ui.grid.theme.IGridTheme;

import com.google.gwt.event.logical.shared.HasShowRangeHandlers;
import com.google.gwt.event.logical.shared.HasValueChangeHandlers;
import com.google.gwt.user.client.EventListener;

/**
 * 
 * @author Olivier Oeuillot (latest modification by $Author: $)
 * @version $Revision: $ $Date: $
 */
public interface IGridWidget extends IUIObject, EventListener,
        HasModelChangedHandlers, HasValueChangeHandlers<IModelChangeState>,
        HasShowRangeHandlers<Integer>, HasPropertyChangedHandlers {

    public enum State {
        CREATED, INITIALIZING, INITIALIZED, CONSTRUCTING, CONSTRUCTED, RENDERING, RENDERED, DESTROYING, DESTROYED;

        public boolean isStarting() {
            return this == CREATED || this == INITIALIZING
                    || this == INITIALIZED;
        }

        public boolean isEnding() {
            return this == DESTROYING || this == DESTROYED;
        }
    }

    State getState();

    IGridTheme getTheme();

    IGridModel getGridModel();

    IGridRenderContext getGridRenderContext();

    IGridModelController getGridModelController();

    IGroupDataModel getGroupDataModel();

    IColumnProvider getColumnProvider();

    boolean isSelectable();

    ISelectionProvider getSelectionProvider();

    boolean isCheckable();

    ICheckProvider getCheckProvider();

    IOverProvider getOverProvider();

    IFocusProvider getFocusProvider();

    IDataModel getDataModel();

    IWidgetsRegistry getWidgetsRegistry();

    int getWidth();

    int getHeight();

    boolean isGridSorted();

    void updateGrid(int firstRowIndex, int rowCount);

    void renderGrid(int firstRowIndex, int rowCount);

    void setFocus(IViewModel viewModel, IElementModel elementModel);

    boolean isFocusAutoSelect();

    IOrderProvider getColumnsOrderProvider();
}
